Remove depth from garmin special data.
authoroliskoli <oliskoli>
Sat, 2 Jun 2007 21:00:37 +0000 (21:00 +0000)
committeroliskoli <oliskoli>
Sat, 2 Jun 2007 21:00:37 +0000 (21:00 +0000)
defs.h
g7towin.c
garmin_fs.c
garmin_fs.h
garmin_txt.c
gdb.c
gpilots.c
mapsource.c
unicsv.c

diff --git a/defs.h b/defs.h
index d7367740fbe284488ddc128ea6f95d568c080441..92057a607be9b6cff8ebda1da7a873f3350a5877 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -289,6 +289,7 @@ typedef struct {
        unsigned int proximity:1;               /* proximity field is set */
        unsigned int course:1;                  /* course field is set */
        unsigned int speed:1;                   /* speed field is set */
+       unsigned int depth:1;                   /* depth field is set */
        /* !ToDo!
        unsigned int altitude:1;                /+ altitude field is set +/
        ... and others
index a3e2517b139e1a960b1ac453117aced7df1c4bef..2aca83e66f9b0a5f3a5a507e1fdb897ea09b8ed8 100644 (file)
--- a/g7towin.c
+++ b/g7towin.c
@@ -173,7 +173,7 @@ parse_line(char *buff, int index, const char *delimiter, waypoint *wpt)
                        case WPT_cC_OFS + 2:
                        case WPT_c5_OFS + 2:
                        case WPT_c8_OFS + 2:
-                               GMSD_SET(depth, altf * atof(cin));
+                               WAYPT_SET(wpt, depth, altf * atof(cin));
                                break;
                                
                        case TRKPT__OFS + 10: /* temperature */
index d9c9a5ece04e3c682b05b982850250af8d7b7d33..2a584b9d72c87cffeef15ffc38d36169307a7487 100644 (file)
@@ -102,7 +102,7 @@ garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt)
        if (gmsd == NULL) return;
        
        if ((gmsd->flags.category && gmsd->category) || 
-            gmsd->flags.depth || 
+            waypt->wpt_flags.depth || 
             waypt->wpt_flags.proximity || 
             waypt->wpt_flags.temperature || 
             gmsd->flags.display)
@@ -115,12 +115,12 @@ garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt)
                        "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " \
                        "xsi:schemaLocation=\"http://www.garmin.com/xmlschemas/GpxExtensions/v2 " \
                        "http://www.garmin.com/xmlschemas/GpxExtensions/v2/GpxExtensionsv2.xsd\">\n", space++ * 2, "");
-               if (waypt->wpt_flags.proximity)
+               if WAYPT_HAS(waypt, proximity)
                        gbfprintf(ofd, "%*s<gpxx:Proximity>%.6f</gpxx:Proximity>\n", space * 2, "", waypt->proximity);
-               if (waypt->wpt_flags.temperature)
+               if WAYPT_HAS(waypt, temperature)
                        gbfprintf(ofd, "%*s<gpxx:Temperature>%.6f</gpxx:Temperature>\n", space * 2, "", waypt->temperature);
-               if (gmsd->flags.depth)
-                       gbfprintf(ofd, "%*s<gpxx:Depth>%.6f</gpxx:Depth>\n", space * 2, "", gmsd->depth);
+               if WAYPT_HAS(waypt, depth)
+                       gbfprintf(ofd, "%*s<gpxx:Depth>%.6f</gpxx:Depth>\n", space * 2, "", waypt->depth);
                if (gmsd->flags.display)
                {
                        char *cx;
@@ -181,15 +181,13 @@ garmin_fs_xml_convert(const int base_tag, int tag, const char *cdatastr, waypoin
 */
        switch(tag) {
        case 2:
-               waypt->proximity = atof(cdatastr); 
-               waypt->wpt_flags.proximity = (*cdatastr); 
+               if (*cdatastr)  WAYPT_SET(waypt, proximity, atof(cdatastr));
                break;
        case 3:
-               waypt->temperature = atof(cdatastr);
-               waypt->wpt_flags.temperature = (*cdatastr);
+               if (*cdatastr) WAYPT_SET(waypt, temperature, atof(cdatastr));
                break;
        case 4:
-               GMSD_SET(depth, atof(cdatastr)); 
+               if (*cdatastr) WAYPT_SET(waypt, depth, atof(cdatastr)); 
                break;
        case 5:
                if (case_ignore_strcmp(cdatastr, "SymbolOnly") == 0) {
@@ -281,7 +279,7 @@ garmin_fs_garmin_after_read(const GPS_PWay way, waypoint *wpt, const int protoid
        if (way->category != 0) GMSD_SET(category, way->category);
        if (way->dst < 1.0e25f) WAYPT_SET(wpt, proximity, way->dst);
        if (way->temperature_populated) WAYPT_SET(wpt, temperature, way->temperature);
-       if (way->dpth < 1.0e25f) GMSD_SET(depth, way->dpth);
+       if (way->dpth < 1.0e25f) WAYPT_SET(wpt, depth, way->dpth);
        GMSD_SETNSTR(cc, way->cc, sizeof(way->cc));
        GMSD_SETNSTR(state, way->state, sizeof(way->state));
        GMSD_SETSTR(city, way->city);
@@ -303,7 +301,7 @@ garmin_fs_garmin_before_write(const waypoint *wpt, GPS_PWay way, const int proto
        way->dspl = gt_switch_display_mode_value(
                GMSD_GET(display, way->dspl), gps_waypt_type, 0);
        way->category = GMSD_GET(category, way->category);
-       way->dpth = GMSD_GET(depth, way->dpth);
+       way->dpth = WAYPT_GET(wpt, depth, way->dpth);
        way->dst = WAYPT_GET(wpt, proximity, way->dpth);
        way->temperature = WAYPT_GET(wpt, temperature, way->temperature);
        
index eda53d320b1697f4ebbf95686e3f0bcc6fbc6273..7c1cd9ab84a6ad43c4b14f86ec0f0e63770ed43a 100644 (file)
@@ -68,7 +68,6 @@ typedef struct {
        unsigned int wpt_class:1;
        unsigned int display:1; 
        unsigned int category:1; 
-       unsigned int depth:1; 
        unsigned int city:1;
        unsigned int state:1;
        unsigned int facility:1;
@@ -91,7 +90,6 @@ typedef struct garmin_fs_s
        int wpt_class;
        gbint32 display;
        gbint16 category;
-       double depth;                   /* depth in meters */
        char *city;                     /* city name */
        char *facility;                 /* facility name */
        char *state;                    /* state */
index 7f17f0b1949235bd97a501c067e9b8134c64253a..baa63b7dbc215ad3e69d7081e32af9ad6c1fe46e 100644 (file)
@@ -576,7 +576,7 @@ write_waypt(const waypoint *wpt)
                print_distance(wpt->altitude, 1, 0);
        gbfprintf(fout, "\t");
        
-       x = GMSD_GET(depth, unknown_alt);
+       x = WAYPT_GET(wpt, depth, unknown_alt);
        if (x != unknown_alt)
                print_distance(x, 1, 0);
        gbfprintf(fout, "\t");
@@ -1129,7 +1129,7 @@ parse_waypoint(void)
                                        &wpt->latitude, &wpt->longitude, MYNAME);
                                break;
                        case  5: if (parse_distance(str, &d)) wpt->altitude = d; break;
-                       case  6: if (parse_distance(str, &d)) GMSD_SET(depth, d); break;
+                       case  6: if (parse_distance(str, &d)) WAYPT_SET(wpt, depth, d); break;
                        case  7: if (parse_distance(str, &d)) WAYPT_SET(wpt, proximity, d); break;
                        case  8: if (parse_temperature(str, &d)) WAYPT_SET(wpt, temperature, d); break;
                        case  9: if (parse_display(str, &i)) GMSD_SET(display, i); break;
diff --git a/gdb.c b/gdb.c
index 96fe4bd49b0475b9682a6beed562346ce37f09e8..5f689122f1f3c4c65127e5d39076a6a3741aa34f 100644 (file)
--- a/gdb.c
+++ b/gdb.c
 
 /*******************************************************************************/
 
-/* static char gdb_release[] = "$Revision: 1.52 $"; */
-static char gdb_release_date[] = "$Date: 2007/05/25 10:13:21 $";
+/* static char gdb_release[] = "$Revision: 1.53 $"; */
+static char gdb_release_date[] = "$Date: 2007/06/02 21:00:37 $";
 
 static gbfile *fin, *fout;
 static int gdb_ver, gdb_category, gdb_via, gdb_roadbook;
@@ -536,7 +536,7 @@ read_waypoint(gt_waypt_classes_e *waypt_class_out)
 
        if (FREAD_C == 1) {
                double depth = gbfgetdbl(fin);
-               GMSD_SET(depth, depth);
+               WAYPT_SET(res, depth, depth);
 #if GDB_DEBUG
                DBG(GDB_DBG_WPTe, 1)
                        printf(MYNAME "-wpt \"%s\" (%d): Depth = %.1f\n",
@@ -896,10 +896,10 @@ read_track(void)
                        wpt->creation_time = FREAD_i32;
                }
                if (FREAD_C == 1) {
-                       wpt->depth = gbfgetdbl(fin);
+                       WAYPT_SET(wpt, depth, gbfgetdbl(fin));
                }
                if (FREAD_C == 1) {
-                       wpt->temperature = gbfgetdbl(fin);
+                       WAYPT_SET(wpt, temperature, gbfgetdbl(fin));
                }
                
                track_add_wpt(res, wpt);
@@ -1154,7 +1154,7 @@ write_waypoint(
        FWRITE_LATLON(wpt->longitude);          /* longitude */
        FWRITE_DBL(wpt->altitude, unknown_alt); /* altitude */
        FWRITE_CSTR(wpt->notes);
-       FWRITE_DBL(WAYPT_GET(wpt, proximity, 0), 0);    /* proximity */
+       FWRITE_DBL(WAYPT_GET(wpt, proximity, unknown_alt), unknown_alt);        /* proximity */
        FWRITE_i32(display);                    /* display */
        FWRITE_i32(0);                          /* color (colour) */
        FWRITE_i32(icon);                       /* icon */
@@ -1162,7 +1162,7 @@ write_waypoint(
        FWRITE_CSTR(GMSD_GET(state, ""));       /* state */
        FWRITE_CSTR(GMSD_GET(facility, ""));    /* facility */
        FWRITE_C(0);                            /* unknown */
-       FWRITE_DBL(GMSD_GET(depth, 0), 0);      /* depth */
+       FWRITE_DBL(WAYPT_GET(wpt, depth, unknown_alt), unknown_alt);    /* depth */
        
        /* VERSION DEPENDENT CODE */
        if (gdb_ver <= GDB_VER_2) {
@@ -1352,6 +1352,7 @@ write_track(const route_head *trk, const char *trk_name)
        
        QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp)
        {
+               double d;
                waypoint *wpt = (waypoint *)elem;
                
                trkpt_ct++;     /* increase informational number of written route points */
@@ -1360,8 +1361,10 @@ write_track(const route_head *trk, const char *trk_name)
                FWRITE_LATLON(wpt->longitude);
                FWRITE_DBL(wpt->altitude, unknown_alt);
                FWRITE_TIME(wpt->creation_time);
-               FWRITE_DBL(wpt->depth, unknown_alt);
-               FWRITE_DBL(wpt->temperature, 0);
+               d = WAYPT_GET(wpt, depth, unknown_alt);
+               FWRITE_DBL(d, unknown_alt);
+               d = WAYPT_GET(wpt, temperature, -99999);
+               FWRITE_DBL(d, -99999);
        }
 
        /* finalize track */
index 8fb1cbcc3c759de5591223a151bff53a75cb9f54..69a2f70a8000b608d39c4270f9203953756590c6 100644 (file)
--- a/gpilots.c
+++ b/gpilots.c
@@ -275,7 +275,7 @@ data_read(void)
                          fi.i = le_read32(&rec->wpt.d108.alt);
                          wpt_tmp->altitude = fi.f;
                          fi.i = le_read32(&rec->wpt.d108.dpth);
-                         wpt_tmp->depth = fi.f;
+                         WAYPT_SET(wpt_tmp, depth, fi.f);
                          fi.i = le_read32(&rec->wpt.d108.dist);
                          WAYPT_SET(wpt_tmp, proximity, fi.f);
                          wpt_tmp->wpt_flags.icon_descr_is_dynamic = 0;
index 3825e7ab48aa6fd9c98444cdc8573eb7a31ef401..c5d4e37135b3323dd17a69dc8864fd0f15fb951e 100644 (file)
@@ -583,7 +583,7 @@ mps_waypoint_r(FILE *mps_file, int mps_ver, waypoint **wpt, unsigned int *mpscla
        thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon);
        thisWaypoint->altitude = mps_altitude;
        if (mps_proximity != unknown_alt) WAYPT_SET(thisWaypoint, proximity, mps_proximity);
-       thisWaypoint->depth = mps_depth;
+       if (mps_depth != unknown_alt) WAYPT_SET(thisWaypoint, depth, mps_depth);
 
        /* might need to change this to handle version dependent icon handling */
        thisWaypoint->icon_descr = gt_find_desc_from_icon_number(icon, MAPSOURCE, &dynamic);
@@ -617,10 +617,11 @@ mps_waypoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt, const int isRou
 
        double  mps_altitude = wpt->altitude;
        double  mps_proximity = (mpsuseprox ? WAYPT_GET(wpt, proximity, unknown_alt) : unknown_alt);
-       double  mps_depth = (mpsusedepth ? wpt->depth : unknown_alt);
+       double  mps_depth = unknown_alt;
        
        lat = GPS_Math_Deg_To_Semi(wpt->latitude);
        lon = GPS_Math_Deg_To_Semi(wpt->longitude);
+       if (WAYPT_HAS(wpt, depth) && mpsusedepth) mps_depth = wpt->depth;
 
        if(wpt->description) src = wpt->description;
        if(wpt->notes) src = wpt->notes;
@@ -1024,7 +1025,7 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte)
                                thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat);
                                thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon);
                                thisWaypoint->altitude = mps_altitude;
-                               thisWaypoint->depth = mps_depth;
+                               if (mps_depth != unknown_alt) WAYPT_SET(thisWaypoint, depth, mps_depth);
                        }
                }
 
@@ -1584,7 +1585,7 @@ mps_track_r(FILE *mps_file, int mps_ver, route_head **trk)
                thisWaypoint->creation_time = le_read32(&dateTime);
                thisWaypoint->microseconds = 0;
                thisWaypoint->altitude = mps_altitude;
-               thisWaypoint->depth = mps_depth;
+               if (mps_depth != unknown_alt) WAYPT_SET(thisWaypoint, depth, mps_depth);
                track_add_wpt(track_head, thisWaypoint);
 
        }               /* while (trk_count--) */
@@ -1682,10 +1683,11 @@ mps_trackdatapoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt)
        char zbuf[10];
 
        double  mps_altitude = wpt->altitude;
-       double  mps_depth = (mpsusedepth ? wpt->depth : unknown_alt);
+       double  mps_depth = unknown_alt;
 
        lat = GPS_Math_Deg_To_Semi(wpt->latitude);
        lon = GPS_Math_Deg_To_Semi(wpt->longitude);
+       if (WAYPT_HAS(wpt, depth) && mpsusedepth) mps_depth = wpt->depth;
 
        memset(zbuf, 0, sizeof(zbuf));
 
index 04e061a976e59cee32bbd13cc84a8d51da71a770..42602a1142fbec3135a20ce4a307e2b0eaf3d6ea 100644 (file)
--- a/unicsv.c
+++ b/unicsv.c
@@ -456,7 +456,7 @@ unicsv_parse_one_line(char *ibuf)
                        break;
 
                case fld_depth:
-                       wpt->depth = atof(s);
+                       WAYPT_SET(wpt, depth, atof(s));
                        break;
                        
                case fld_terminator: /* dummy */